package qdu.rg05.ch1_intent_adv;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

import androidx.annotation.Nullable;

public class Act_return extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ly_actret);

        findViewById(R.id.btn_ret).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String msg = "";
                msg=((EditText)findViewById(R.id.et_remsg)).getText().toString();

                if(msg.hashCode() == 0 || msg.equals("") ) {
                    msg = "nothing";
                    //Log.i("mytag","if hascode -> 0");
                }

                Intent it = new Intent();
                it.putExtra("msg", msg);
                setResult( 0x123, it);

                //Log.i("mytag","msg="+msg);
                finish();//结束当前组件
            }
        });
    }

    @Override
    protected void onPause() {

        super.onPause();
    }
}
